<template>
<div class="layerRtb layerRtb-threecolumn">
    <three-title :title="{name:'要点'}"></three-title>
    <div class="layerRtb-scroll thinScroll" v-scrollHeight = "270">
            <div class="analyItem">
                <p class="analyItemTit tx-center bgdeepgreen">招聘</p>
                 <div class="analyItemCon">
                     <a href="javascript:;" class="circlemark-green circlemark">100</a>
                    </div>
            </div>
        <div class="analyItem">
            <p class="analyItemTit tx-center">咨询</p>
            <div class="analyItemCon">
                <a href="javascript:;" class="circlemark-lightRed circlemark">0</a>
                </div>
            </div>
    </div>
    <div class="layerRtb-footer" style="height:270px;">
        <div class="analyItem">
            <p class="analyItemTit tx-center">综合</p>
            <div class="analyItemCon">
                <p class="col-md-4"><span name="" class="cLightGray pr8">分司</span> <span name="region" class="cLightGray pr8">{{this.siName}}</span></p>
                <p class="col-md-4"><span name="" class="cLightGray pr8">姓名</span> <span name="name" class="cLightGray pr8">{{this.leftInfo.user_name}}</span></p>
                <p class="col-md-4"><span name="" class="cLightGray pr8">电话</span> <span name="mobile" class="cLightGray pr8">{{this.leftInfo.mobile}}</span></p>
                <p class="col-md-4" v-if="Number(this.leftInfo.stId) === 4 || Number(this.leftInfo.stId) === 5"><span name="" class="cLightGray pr8">平台服务费</span> <span name="" class="cLightGray pr8">{{ Number(this.moneys.platformMoney) > 0 ? this.moneys.platformMoney : 0}}</span></p>
                <p class="col-md-4" v-if="Number(this.leftInfo.stId) === 4 || Number(this.leftInfo.stId) === 5"><span name="" class="cLightGray pr8">已缴</span> <span name="" class="cLightGray pr8">{{Number(this.moneys.pmDeposit) > 0 ? this.moneys.pmDeposit : 0}}</span></p>
                <p class="col-md-4" v-if="Number(this.leftInfo.stId) === 4 || Number(this.leftInfo.stId) === 5"><span name="" class="cightGray pr8L">缴纳时间</span> <span name="" class="cLightGray pr8">{{this.moneys.depositUpdateTime ? this.moneys.depositUpdateTime : '未缴'}}</span></p>
            </div>
        </div>
        <div class="clearfix">
            <div class="col-md-7 handle-left pb10" style="min-height: 172px;">
                <div class="clearfix">
                    <h2 class="uiTitle2 mt3">
                        <i class="uiTitle-icon"></i>
                        处理
                    </h2>
                    <ul class="topdaily">
                        <li class="cRed">
                            <a @click="choice(0)" :class="{'cRed':this.flag == 0}" class="topdailybtn" href="javascript:">淘汰</a>
                        </li>
                        <li>
                            <!--  v-if="Number(this.leftInfo.stId) === 4 || Number(this.leftInfo.stId) === 0" -->
                            <a @click="choice(1)" v-if="Number(this.leftInfo.stId) === 4 || Number(this.leftInfo.stId) === 5" :class="{'cRed':this.flag == 1}" class="topdailybtn" href="javascript:">转培</a>
                        </li>
                        <!-- <li>
                            <a @click="choice(8)" :class="{'cRed':this.flag == 8}" class="topdailybtn" href="javascript:">问题</a>
                        </li> -->
                    </ul>
                    <!-- <div class="choice-item pt10"> -->
                        <!-- 5 -->
                        <!-- <el-button @click="changeT()" class="choice-span">淘汰</el-button> -->
                        <!--  v-if="Number(this.leftInfo.stId) === 4 || Number(this.leftInfo.stId) === 0" -->
                        <!-- data_mark="" -->
                        <!-- <el-button @click="changeZ()" an class="choice-span">转培</el-button >
                    </div> -->
                    <div class="clearfix pb10 pr10 pt10">
                        <textarea name="statusHandleContent" class="evaluate-textarea" v-model="logcontent"></textarea>
                    </div>
                </div>
            </div>
            <div class="col-md-5 fl operate-bottomDiv EventBanner pt20 pl10 relative" style="overflow: hidden;">
                <div class="pt10 tx-center" style="padding: 85px 0px 10px;">
                    <input type="button" value="提交" name="buttonStatusHandleClick" class="uiBtn-normal uiBtn-blue  operate-submit" @click="submit()">
                </div>
            </div>
        </div>
    </div>
</div>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
import { GetRegionList, getPlatformMoney, updateStayLevelId, updateZhaoUserState, findReferrerUid, insertZhaoSurLog } from '../Resources/Api'
export default {
    data () {
        return {
            logcontent: '',
            flag: 0,
            regionList: [], // 所有的地区
            siName: '', // 分司名称
            moneys: [], // 用户的平台费
            taoTai: 1, // 等级
            zhuanPei: 0 // 转培
        }
    },
    created () {
        this.GetRegionList()
        this.getPlatformMoney()
    },
    methods: {
        ...mapMutations({
            setUpdateLeft: `SET_UPDATE_LEFT`
        }),
        // 提交
        submit () {
            if (Number(this.zhuanPei) !== 0 && (Number(this.leftInfo.stId) === 4 || Number(this.leftInfo.stId) === 5)) {
                // this.updateStayLevelId()
                this.updateZhaoUserState()
                // this.setUpdateLeft()
            } else if (Number(this.taoTai) !== 0) {
                this.findReferrerUid()
                this.insertZhaoSurLog()
                // this.setUpdateLeft()
            }
        },
        // 查询推荐人uid
        findReferrerUid () {
            findReferrerUid({
                uid: this.leftInfo.uid
            }).then(result => {

            }).catch(err => {
                console.log('查询推荐人uid失败findReferrerUid，异常信息：' + err)
            })
        },
        // 添加回访信息
        insertZhaoSurLog () {
            if (this.logcontent === '') {
                layer.msg('请输入回访内容')
                return
            }
            insertZhaoSurLog({
                logcontent: this.logcontent, // 回访内容
                importance: 5, // 状态  5-历史， 1-正常
                orderno: this.leftInfo.uid
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    // 一段要刷新
                    this.setUpdateLeft()
                }
            }).catch(err => {
                console.log('insertZhaoSurLog请求失败，异常信息：' + err)
            })
        },
        // 添加回访信息
        insertZhaoSurLog1 () {
            if (this.logcontent === '') {
                layer.msg('请输入回访内容')
                return
            }
            insertZhaoSurLog({
                logcontent: this.logcontent, // 回访内容
                importance: 1, // 状态  5-历史， 1-正常
                orderno: this.leftInfo.uid
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    // 一段要刷新
                    this.setUpdateLeft()
                }
            }).catch(err => {
                console.log('insertZhaoSurLog请求失败，异常信息：' + err)
            })
        },
        // 修改招的状态
        updateZhaoUserState () {
            if (this.logcontent === '') {
                layer.msg('请输入回访内容')
                return
            }
            updateZhaoUserState({
                uid: this.leftInfo.uid, // 用户id
                userState: 2 // 用户状态 正常
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    this.updateStayLevelId()
                }
            }).catch(err => {
                console.log('修改招的状态失败updateZhaoUserState，异常信息：' + err)
            })
        },
        // 修改项目经理各个阶段的等级
        updateStayLevelId () {
            updateStayLevelId({
                userId: this.leftInfo.uid, // 用户id
                leId: 3, // 等级
                SourceCode: '签约', // 凭证号
                UserNo: this.userInfo.as_cardNo,
                UserName: this.userInfo.as_fullName
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    layer.msg('提交成功')
                    this.insertZhaoSurLog1()
                    // 一段要刷新
                    this.setUpdateLeft()
                }
            }).catch(err => {
                console.log('修改项目经理各个阶段的等级失败updateStayLevelId，异常信息：' + err)
            })
        },
        choice (index) {
            this.flag = index
            if (Number(index) === 0) {
                // alert('changeT')
                this.changeT()
            }
            if (Number(index) === 1) {
                this.changeZ()
            }
        },
        // 淘汰
        changeT () {
            // alert(Number(this.taoTai))
            if (Number(this.zhuanPei) !== 0) {
                this.zhuanPei = 0
                this.taoTai = 1
            } else if (Number(this.taoTai) !== 0) {
                this.taoTai = 0
            }
            this.taoTai = 1
            // alert(Number(this.taoTai))
        },
        // 转培
        changeZ () {
            // alert(Number(this.zhuanPei))
            if (Number(this.taoTai) !== 0) {
                this.taoTai = 0
                this.zhuanPei = 1
            } else if (Number(this.zhuanPei) !== 0) {
                this.zhuanPei = 0
            }
            this.zhuanPei = 1
            // alert(Number(this.zhuanPei))
        },
        // 查询指定用户的平台服务费和押金
        getPlatformMoney () {
            getPlatformMoney({
                uid: this.leftInfo.uid
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    result.data.Body.moneyMaps.forEach(money => {
                        if (Number(money.pmDataSource) === 17) {
                            this.moneys = result.data.Body.moneyMaps
                            return this.moneys
                        }
                    })
                }
            }).catch(err => {
                console.log('查询指定用户的平台服务费和押金失败getPlatformMoney，异常信息：' + err)
            })
        },
        // 查询所有的分司
        GetRegionList () {
            GetRegionList().then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    this.regionList = result.data.Body
                    this.regionList.forEach(region => {
                        // this.leftInfo.areaId == 分司id
                        if (Number(region.regionId) === this.leftInfo.areaId) {
                            this.siName = region.regionName
                            return this.siName
                        }
                    })
                }
            }).catch(err => {
                console.log('查询所有的分司失败GetRegionList，异常信息：' + err)
            })
        }

    },
    computed: {
        ...mapGetters(['leftInfo', 'userInfo'])
    }
}
</script>
<style scoped>
a.topdailybtn.cRed {
  color: #fff;
  background-color: #0e92ff;
}
</style>

